<?php
error_reporting(E_ERROR);
#连接数据库
$conn = mysqli_connect("localhost", "userid", "password", "dbname");
#判断是否连接成功
if (!$conn) {echo "失败";}
//选择数据库
mysqli_select_db($conn, '');

function get_data($url) {
    $ch = curl_init();
    $timeout = 30;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}  